<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title th:text="用户仪表板"></title>
    <link rel="stylesheet" type="text/css" href="/plugins/vali/css/main.css">
    <link rel="stylesheet" type="text/css" href="/plugins/toast/jquery.toast.css">
    <link rel="stylesheet" type="text/css" href="/plugins/font-awesome-4.7.0/css/font-awesome.min.css">
</head>
<body class="app sidebar-mini">
    <!-- 头部 -->
    <header class="app-header">
        <a class="app-header__logo" href="/user/dashboard">用户中心</a>
        <a class="app-sidebar__toggle" href="#" data-toggle="sidebar" aria-label="Hide Sidebar"></a>
        <ul class="app-nav">
            <li class="dropdown">
                <a class="app-nav__item" href="#" data-toggle="dropdown" aria-label="Open Profile Menu">
                    <i class="fa fa-user fa-lg"></i>
                </a>
                <ul class="dropdown-menu settings-menu dropdown-menu-right">
                    <li><a class="dropdown-item" href="/user/profile"><i class="fa fa-user fa-lg"></i> 个人资料</a></li>
                    <li><a class="dropdown-item" href="/user/logout"><i class="fa fa-sign-out fa-lg"></i> 退出登录</a></li>
                </ul>
            </li>
        </ul>
    </header>
    
    <!-- 侧边栏 -->
    <div class="app-sidebar__overlay" data-toggle="sidebar"></div>
    <aside class="app-sidebar">
        <div class="app-sidebar__user">
            <img class="app-sidebar__user-avatar" 
                 th:src="${session.user_session.userPortrait == null ? '/static/img/portrait.jpg' : session.user_session.userPortrait}" 
                 alt="User Image" width="48px" height="48px">
            <div>
                <p class="app-sidebar__user-name" th:text="${session.user_session.userDisplayName}"></p>
                <p class="app-sidebar__user-designation">博客用户</p>
            </div>
        </div>
        <ul class="app-menu">
            <li>
                <a class="app-menu__item active" href="/user/dashboard">
                    <i class="app-menu__icon fa fa-dashboard"></i>
                    <span class="app-menu__label">仪表板</span>
                </a>
            </li>
            <li>
                <a class="app-menu__item" href="/user/articles">
                    <i class="app-menu__icon fa fa-file-text"></i>
                    <span class="app-menu__label">文章管理</span>
                </a>
            </li>
            <li>
                <a class="app-menu__item" href="/user/my-activities">
                    <i class="app-menu__icon fa fa-calendar"></i>
                    <span class="app-menu__label">我参与的活动</span>
                </a>
            </li>
            <li>
                <a class="app-menu__item" href="/user/profile">
                    <i class="app-menu__icon fa fa-user"></i>
                    <span class="app-menu__label">个人资料</span>
                </a>
            </li>
            <li>
                <a class="app-menu__item" href="/" target="_blank">
                    <i class="app-menu__icon fa fa-home"></i>
                    <span class="app-menu__label">返回主页</span>
                </a>
            </li>
        </ul>
    </aside>
    
    <!-- 主内容区 -->
    <main class="app-content">
        <div class="app-title">
            <div>
                <h1><i class="fa fa-dashboard"></i> 仪表板</h1>
                <p>欢迎使用用户中心</p>
            </div>
            <ul class="app-breadcrumb breadcrumb">
                <li class="breadcrumb-item"><i class="fa fa-home fa-lg"></i></li>
                <li class="breadcrumb-item"><a href="#">仪表板</a></li>
            </ul>
        </div>
        
        <!-- 统计卡片 -->
        <div class="row">
            <div class="col-md-6 col-lg-3">
                <div class="widget-small primary coloured-icon">
                    <i class="icon fa fa-file-text fa-3x"></i>
                    <div class="info">
                        <h4>我的文章</h4>
                        <p><b th:text="${articleCount}">0</b></p>
                    </div>
                </div>
            </div>
            <div class="col-md-6 col-lg-3">
                <div class="widget-small info coloured-icon">
                    <i class="icon fa fa-calendar fa-3x"></i>
                    <div class="info">
                        <h4>今天日期</h4>
                        <p><b th:text="${#dates.format(#dates.createNow(), 'yyyy-MM-dd')}">2025-05-13</b></p>
                    </div>
                </div>
            </div>
            <div class="col-md-6 col-lg-3">
                <div class="widget-small warning coloured-icon">
                    <i class="icon fa fa-user fa-3x"></i>
                    <div class="info">
                        <h4>我的资料</h4>
                        <p><b><a href="/user/profile">点击查看</a></b></p>
                    </div>
                </div>
            </div>
            <div class="col-md-6 col-lg-3">
                <div class="widget-small danger coloured-icon">
                    <i class="icon fa fa-pencil fa-3x"></i>
                    <div class="info">
                        <h4>写博客</h4>
                        <p><b><a href="/admin/article/new" target="_blank">去撰写</a></b></p>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 最近文章 -->
        <div class="row">
            <div class="col-md-12">
                <div class="tile">
                    <h3 class="tile-title">最近发布的文章</h3>
                    <div class="table-responsive">
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>标题</th>
                                    <th>发布时间</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr th:each="article : ${articles}">
                                    <td th:text="${article.articleTitle}">文章标题</td>
                                    <td th:text="${#dates.format(article.articleNewstime, 'yyyy-MM-dd HH:mm')}">2025-05-13</td>
                                    <td>
                                        <span class="badge badge-success" th:if="${article.articleStatus == 0}">已发布</span>
                                        <span class="badge badge-warning" th:if="${article.articleStatus == 1}">草稿</span>
                                        <span class="badge badge-danger" th:if="${article.articleStatus == 2}">回收站</span>
                                    </td>
                                    <td>
                                        <a th:href="@{'/admin/article/edit?articleId='+${article.id}}" target="_blank">
                                            <button class="btn btn-primary btn-sm">编辑</button>
                                        </a>
                                        <a th:href="${article.articleUrl}" target="_blank">
                                            <button class="btn btn-info btn-sm">查看</button>
                                        </a>
                                    </td>
                                </tr>
                                <tr th:if="${#lists.isEmpty(articles)}">
                                    <td colspan="4" style="text-align: center;">暂无文章</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="tile-footer">
                        <a class="btn btn-primary" href="/user/articles">查看全部文章</a>
                    </div>
                </div>
            </div>
        </div>
    </main>
    
    <!-- 脚本 -->
    <script src="/plugins/vali/js/jquery-3.2.1.min.js"></script>
    <script src="/plugins/vali/js/popper.min.js"></script>
    <script src="/plugins/vali/js/bootstrap.min.js"></script>
    <script src="/plugins/vali/js/main.js"></script>
    <script src="/plugins/toast/jquery.toast.js"></script>
</body>
</html>
